package net.cathackers.devel.scmp.chat.interfaces;

import java.util.Set;

import net.cathackers.devel.exceptions.CATException;
import net.cathackers.devel.scmp.auth.interfaces.UserID;
import net.cathackers.devel.scmp.auth.interfaces.UserProfile;
import net.cathackers.devel.scmp.interfaces.Envelope;
import net.cathackers.devel.scmp.interfaces.ServiceType;
import net.cathackers.devel.scmp.xmpp.Packet;
import net.cathackers.devel.scmp.xmpp.exceptions.UnknownPacket;

import org.dom4j.Document;

public interface ChatManager {

    public abstract String getGUID();


    public abstract ServiceType getServiceType();

    /**
     * should convert a lobby user into a real authenticated user
     * 
     * @param credentials
     * @param lobbyUser
     * @return
     */
    public abstract void registerSession(ChatSession session);


    public abstract String getName();


    public abstract void shutdown();

    public abstract void handle(Envelope envelope) throws CATException;

    public abstract void initialize() throws CATException;

    public abstract void registerNewServiceManagerCallBack();

    public abstract void unregisterServiceManagerCallBack();

    public abstract UserProfile getUserProfile(UserID userID);

    public abstract String generateSessionID();

    public abstract boolean unregisterSession(ChatSession session);

    public abstract boolean destroySession(String sessionID);

    public abstract ChatSession createSession(String serverName,
	    Document initDoc, XMPPConnection connection);

    public abstract void deliverToUser(Packet packet);

    public abstract void route(Packet packet);

    public abstract void route(Document doc, String sessionID)
	    throws UnknownPacket;

    public abstract ChatSession[] getChatSession(UserID userID);

    public abstract ChatSession getChatSession(String sessionID);

    public abstract boolean checkIfSessionOnline(UserID userID);

    public abstract void identifySession(String sessionID);
    
    public abstract void addSubscriber(UserID owner, UserID subscriber);
    
    public abstract void removeSubscriber(UserID owner, UserID subscriber);
    
    public abstract Set<UserID> getSubscribers(UserID owner);
    
    public abstract void removeSubscribersCacheElement(UserID owner);


}